home *** CD-ROM | disk | FTP | other *** search
/ Shareware Grab Bag / Shareware Grab Bag.iso / 095 / convert.lqr / CONVERT.C next >
Text File  |  1985-06-03  |  8KB  |  252 lines

  1. /********************************************************************
  2. CONV124A.C             (c) 1985 John Zimmatore
  3.  
  4. This program converts the RBBS USERS file to the Fido USER.BBS file
  5. format. This version is compatible with RBBS Version CPC12-4A.
  6.     All program rights are retained by the author. The program may
  7. be distributed on an as is basis and may not be modified.
  8.     The author assumes no liability nor responsibility for damages,
  9. monetary or otherwise, incurred from the use of the program.
  10. *********************************************************************/
  11.  
  12.  
  13.  
  14. #include <dos.h>
  15. #include <tip.h>
  16. #include <stdio.h>
  17. #include <fcntl.h>
  18.  
  19. struct TDB tdb;
  20.  
  21. struct RBBS     {
  22.                  char n [31];
  23.                  char pw [15];
  24.                  int sl;
  25.                  int tga;
  26.                  int lo;
  27.                  char lg[1];
  28.                  char gr[1];
  29.                  int mq;
  30.                  int bf;
  31.                  int resv1;
  32.                  char pl[1];
  33.                  char resv2[1];
  34.                  char cs [24];
  35.                  char ma [19];
  36.                  char td [14];
  37.                  char lnd [3];
  38.                  char udl [2];
  39.                  char uul [2];
  40.                  char et [2];
  41.                }rbbs;
  42.  
  43. struct FIDO    {
  44.                 char name [36];
  45.                 char city [36];
  46.                 int date [20];
  47.                 char pwd [16];
  48.                 int times;
  49.                 int help;
  50.                 int tabs;
  51.                 int nulls;
  52.                 int msg;
  53.                 int more;
  54.                 int priv;
  55.                 char ldate [20];
  56.                 int time;
  57.                 unsigned flag;
  58.                 unsigned upld;
  59.                 unsigned dnld;
  60.                 unsigned dnldl;
  61.                 int files;
  62.                 char width;
  63.                 char len;
  64.                 int credit;
  65.                 int debit;
  66.                }fido;
  67.  
  68. char fdate [15];
  69.  
  70. main()
  71. {
  72.  
  73.               logon ();
  74.               close(3);
  75.               close (4);
  76. }
  77.  
  78.  
  79.  
  80. logon()
  81. {
  82. char resp, presp, c;
  83.  
  84.              tsetup("ibmpc.d");
  85.              tinit();
  86.              tputc(TO_VR);
  87.              tputs("RBBS to Fido User File Conversion Utility        (c) 1985 John Zimmatore        ");
  88.              tputc(TO_VN);
  89.              puts("\n\n");
  90.              puts("This utility will convert the RBBS USERS File to Fido's USER.BBS file format.");
  91.              puts("You are prompted for the initial privledge level for the user (See the Fido");
  92.              puts("documentation for more information on this). You can (B)ulk convert the entire");
  93.              puts("RBBS USERS file, or you can (S)ingle Step through the RBBS USERS file and");
  94.              puts("selectively add users to your Fido USER.BBS file. This utility sets initial");
  95.              puts("MESSAGE and FILE areas to 1 and the HELP level to NOVICE.");
  96.              printf("\n\nSet Initial Privledge Level: (T)wit   (D)isgrace  (N)ormal   Enter Choice:  ");
  97.              presp = getche();
  98.              c = toupper(presp);
  99.              switch(c)
  100.               {
  101.                  case 'T': fido.priv = -2;
  102.                  break;
  103.                  case 'D': fido.priv = 0;
  104.                  break;
  105.                  case 'N': fido.priv = 2;
  106.                  break;
  107.                  default: fido.priv = 0;
  108.                  break;
  109.               }
  110.              printf("\n\n\n(B)ulk Convert  (S)ingle Step  CTL C to abort.   Enter choice:  ");
  111.              resp = getchar();
  112.              c = toupper(resp);
  113.              if(c == 'B')
  114.                 bulk_copy();
  115.              else if(c == 'S')
  116.                 single_step();
  117.              else
  118.                 logon();
  119. }
  120.  
  121.  
  122. make_ready()
  123. {
  124. int i;
  125.                       for(i = 0; i < sizeof(rbbs.td); ++i)
  126.                         {
  127.                           fdate[i] = rbbs.td[i];
  128.                           fdate[i + 1] = '\0';
  129.                         }
  130.                       for(i = 0; i < sizeof(rbbs.n); ++i)
  131.                         {
  132.                           fido.name[i] = rbbs.n[i];
  133.                           fido.name[i + 1] = '\0';
  134.                         }
  135.                       for(i = 0; i < sizeof(rbbs.pw); ++i)
  136.                         {
  137.                           fido.pwd[i] = rbbs.pw[i];
  138.                           fido.pwd[i + 1] = '\0';
  139.                         }
  140.                       for(i = 0; i < sizeof(rbbs.cs); ++i)
  141.                         {
  142.                           fido.city[i] = rbbs.cs[i];
  143.                           fido.city[i + 1] = '\0';
  144.                         }
  145.                       fido.help = 6;
  146.                       fido.msg = 1;
  147.                       fido.files = 1;
  148. }
  149.  
  150. bulk_copy ()
  151. {
  152. int a,i, count = 0;
  153.  
  154.               init();
  155.               puts("RBBS to Fido Conversion Utility    Bulk Conversion");
  156.               while((a = read(3, &rbbs, sizeof(rbbs))) > 0)
  157.                  {
  158.                    make_ready();
  159.                    if(rbbs.n[0] != 0)
  160.                       {
  161.                         ++count;
  162.                         tputc(TO_MC, 3, 0);
  163.                         printf("Converting......%s  Number converted: %d", fido.name, count);
  164.                         case_change(fido.name);
  165.                         case_change(fido.pwd);
  166.                         case_change(fido.city);
  167.                         write_usr();
  168.                       }
  169.                  }
  170.                puts("\n\n\nConversion complete!");
  171. }
  172.  
  173.  
  174. single_step ()
  175. {
  176. int a,i, c, count = 0;
  177. char reply;
  178.  
  179.               init();
  180.               puts("RBBS to Fido Conversion Utility   Single Step");
  181.               while((a = read(3, &rbbs, sizeof(rbbs))) > 0)
  182.                  {
  183.                    make_ready();
  184.                    if(rbbs.n[0] != 0)
  185.                       {
  186.                         tputc(TO_MC, 4, 0);
  187.                         printf("User Name: %s Last RBBS access: %s", fido.name, fdate);
  188.                         tputc(TO_MC, 6, 0);
  189.                         printf("Include (Y/N)?  ");
  190.                         reply = getch();
  191.                         c = toupper(reply);
  192.                         if(c == 'Y')
  193.                           {
  194.                             case_change(fido.name);
  195.                             case_change(fido.pwd);
  196.                             case_change(fido.city);
  197.                             write_usr();
  198.                             ++count;
  199.                           }
  200.                             tputc(TO_MC, 8, 0);
  201.                             printf("Nunber of users converted: %d", count);
  202.                       }
  203.                  }
  204.                printf("\n\n\n\nEnd of user file. Conversion Complete!");
  205. }
  206.  
  207. case_change (strg)
  208. char strg[];
  209. {
  210. int i, length;
  211.  
  212.        length = strlen(strg);
  213.        for(i = 1; i < length + 1; ++i)
  214.          {
  215.           if(strg[i - 1] != ' ')
  216.           if(strg[i - 1] != ',')
  217.           strg[i] = tolower(strg[i]);
  218.          }
  219.        return(strg);
  220. }
  221.  
  222. init()
  223. {
  224. int error, err;
  225.  
  226.               tputc(TO_CS);
  227.               err = open("users",0x8000);
  228.               if(err == -1)
  229.                {
  230.                   printf("\n\nRBBS Users file is missing!");
  231.                   exit();
  232.                }
  233.               creat("user.bbs");
  234.               open("user.bbs",0x8002);
  235. }
  236.  
  237.  
  238. write_usr()
  239. {
  240. int status;
  241.  
  242.                         status = write(4, &fido, sizeof(fido));
  243.                          if(status < sizeof(fido))
  244.                           {
  245.                            printf("\n\nWrite error or not enough room to create file!");
  246.                            close (3);
  247.                            close (4);
  248.                            unlink("user.bbs");
  249.                            exit();
  250.                           }
  251. }
  252.